"""
WSGI config for mgtServer project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
"""

import os
from threading import Thread
from django.core.wsgi import get_wsgi_application
from onu.models import OltInfo
from tools.autoregister.autoregister import hwolt_run as Huawei
from tools.autoregister.zte_autoregister import hwolt_run as ZTE

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mgtServer.settings')

application = get_wsgi_application()

oltList = list()
allData = OltInfo.objects.all()

for data in allData:
    if data.olt_mode == "华为":
        oltThread = Thread(target=Huawei, args=(data.olt_ip, data.olt_port, data.olt_account, data.olt_passwd))
    else:
        oltThread = Thread(target=ZTE, args=(data.olt_ip, data.olt_port, data.olt_account, data.olt_passwd))
    oltList.append(oltThread)
for olt in oltList:
    olt.start()
